﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace NCKH
{
    public partial class Trangchu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hientinnoibat();
                hientintuc();
                hientintuc1();
            }
        }
        protected void hientinnoibat()
        {
            string connection = ConfigurationManager.ConnectionStrings["NCKH"].ConnectionString;
            //string select_tin = "SELECT Image, Tieude, Tomtat, FROM NOIDUNGTIN WHERE bhienthi='true' and trangthaitin='New'";
            using (SqlConnection cnn = new SqlConnection(connection))
            {
                using (SqlCommand cmd = new SqlCommand("select_hottin", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable tb = new DataTable();
                        da.Fill(tb);
                        grvtinoibat.DataSource = tb;
                        grvtinoibat.DataBind();
                    }
                }
            }
        }
        protected void hientintuc()
        {
            string connection = ConfigurationManager.ConnectionStrings["NCKH"].ConnectionString;
            //string select_tin = "SELECT Image, Tieude, Tomtat, FROM NOIDUNGTIN WHERE bhienthi='true' and trangthaitin=N'đọc nhiều'";
            using (SqlConnection cnn = new SqlConnection(connection))
            {
                using (SqlCommand cmd = new SqlCommand("select_newtin", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable tb = new DataTable();
                        da.Fill(tb);
                        grvtin2.DataSource = tb;
                        grvtin2.DataBind();
                    }
                }
            }
        }
        protected void hientintuc1()
        {
            string connection = ConfigurationManager.ConnectionStrings["NCKH"].ConnectionString;
            //string select_tin = "SELECT Image, Tieude, Tomtat, FROM NOIDUNGTIN WHERE bhienthi='true'";
            using (SqlConnection cnn = new SqlConnection(connection))
            {
                using (SqlCommand cmd = new SqlCommand("select_tin", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable tb = new DataTable();
                        da.Fill(tb);
                        grvtin.DataSource = tb;
                        grvtin.DataBind();
                    }
                }
            }
        }

        protected void grvtinoibat_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void grvtinoibat_SelectedIndexChanged1(object sender, EventArgs e)
        {

        }

        protected void grvtinoibat_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void grvtinoibat_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvtinoibat.PageIndex = e.NewPageIndex;
            hientinnoibat();
        }

        protected void grvtin2_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {


        }

        protected void grvtin2_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvtin2.PageIndex = e.NewPageIndex;
            hientintuc();
        }

        protected void grvtin_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void grvtin_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvtin.PageIndex = e.NewPageIndex;
        }
    }
}